
<template>
  <div id="three-container"></div>
</template>

<script>
import * as THREE from 'three';




export default {
  name: 'ThreeJsComponent',
  mounted() {
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 3000);
    const renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.getElementById('three-container').appendChild(renderer.domElement);



    let lightTexture = new THREE.TextureLoader().load("../assets/images/earth.jpg");
    let lightEarthGeometry = new THREE.SphereGeometry(10, 32, 32);
    let lightEarthMaterial = new THREE.MeshBasicMaterial({
      map: lightTexture,
      alphaMap: lightTexture,
      blending: THREE.AdditiveBlending,
      transparent: true,
    });
    let lightEarth = new THREE.Mesh(lightEarthGeometry, lightEarthMaterial);
    scene.add(lightEarth);

    //移动相机位置
    camera.position.z = 16;
    camera.position.x = 15;

    function render() {
      //渲染循环，以每秒60次的频率来绘制场景
      requestAnimationFrame(render);
      //设置球体绕y轴旋转
      //ball.rotation.y += 0.001;
      lightEarth.rotation.y += 0.001;
      renderer.render(scene, camera);

    }
    render();
  }
}
</script>


<style scoped lang="scss">
.body-main-third-ball{
  pointer-events: auto;
  user-select: auto;
  visibility: visible;
  height: 800px;
  width: 100%;
}

.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}
</style>

